﻿package mortal.game.view.common.tooltip.tooltips.equipment
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.common.tools.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;

    public class ToolTipPrescriptionPart extends GSprite
    {
        private var _timeTxt:GTextFiled;
        private var _createDate:Date;
        private var _lineTime:ScaleBitmap;
        private var _data:ItemData;

        public function ToolTipPrescriptionPart()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._lineTime = UIFactory.bg(-14, 0, 256, 2, this, ImagesConst.SplitLine);
            this._timeTxt = UIFactory.gTextField(Language.getStringByParam(20758, ""), 0, 160, 230, 20, this, GlobalStyle.textFormatHuang);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._lineTime.dispose(param1);
            this._lineTime = null;
            this._timeTxt.dispose(param1);
            this._timeTxt = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function set data(param1:ItemData) : void
        {
            this._data = param1;
            this._timeTxt.y = this._lineTime.y + 6;
            var _loc_2:* = ClockManager.instance.nowDate;
            if (this._data.serverData)
            {
                if (this._data.extInfo && this._data.extInfo.app_dt)
                {
                    this._createDate = DateParser.strToDateNormal(this._data.extInfo.app_dt);
                }
                else if (this._data.serverData.createDt)
                {
                    this._createDate = this._data.serverData.createDt;
                }
                else
                {
                    this._createDate = _loc_2;
                }
            }
            else
            {
                this._createDate = this._createDate;
            }
            this.updateLeftTime();
            return;
        }// end function

        private function updateLeftTime() : void
        {
            var _loc_1:int = 0;
            var _loc_3:Date = null;
            var _loc_2:* = ClockManager.instance.nowDate;
            if (this._data.itemInfo.existTime)
            {
                _loc_3 = new Date(this._createDate.time + this._data.itemInfo.existTime * 60 * 1000);
            }
            else
            {
                _loc_3 = new Date(this._createDate.fullYear, this._createDate.month, this._createDate.date + this._data.itemInfo.prescription, 0, 0, 0);
            }
            if (this._createDate)
            {
                if (!ItemsUtil.isPrescriOutTime(this._data as ItemData))
                {
                    this._timeTxt.text = Language.getStringByParam(20758, DateParser.parse(_loc_3, Language.getString(21384)));
                }
                else
                {
                    this._timeTxt.htmlText = Language.getString(20759);
                }
            }
            else
            {
                this._timeTxt.text = Language.getStringByParam(20758, DateParser.parse(_loc_3, Language.getString(21384)));
            }
            return;
        }// end function

    }
}
